﻿Imports System
Imports System.Runtime.Serialization
Imports System.Security.Permissions
Imports System.Workflow.ComponentModel.Compiler

Namespace System.Workflow.Activities.Rules
    <Serializable> _
    Public Class RuleSetValidationException
        Inherits RuleException
        Implements ISerializable
        ' Methods
        Public Sub New()
        End Sub

        Public Sub New(ByVal message As String)
            MyBase.New(message)
        End Sub

        Protected Sub New(ByVal serializeInfo As SerializationInfo, ByVal context As StreamingContext)
            MyBase.New(serializeInfo, context)
            If (serializeInfo Is Nothing) Then
                Throw New ArgumentNullException("serializeInfo")
            End If
            Me.m_errors = DirectCast(serializeInfo.GetValue("errors", GetType(ValidationErrorCollection)), ValidationErrorCollection)
        End Sub

        Public Sub New(ByVal message As String, ByVal ex As Exception)
            MyBase.New(message, ex)
        End Sub

        Public Sub New(ByVal message As String, ByVal errors As ValidationErrorCollection)
            MyBase.New(message)
            Me.m_errors = errors
        End Sub

        <SecurityPermission(SecurityAction.Demand, SerializationFormatter:=True)> _
        Public Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext)
            If (info Is Nothing) Then
                Throw New ArgumentNullException("info")
            End If
            MyBase.GetObjectData(info, context)
            info.AddValue("errors", Me.m_errors)
        End Sub


        ' Properties
        Public ReadOnly Property Errors As ValidationErrorCollection
            Get
                Return Me.m_errors
            End Get
        End Property


        ' Fields
        Private m_errors As ValidationErrorCollection
    End Class
End Namespace

